#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    double findMaxAverage(vector<int>& nums, int k) {
        double sum = 0;
        int i = 0;
        for (; i < k; i++)
        {
            sum += nums[i];
        }
        double ret = sum / k;
        int n = nums.size();
        for (; i < n; i++)
        {
            sum -= nums[i - k];
            sum += nums[i];
            ret = max(ret, sum / k);
        }
        return ret;
    }
};